package com.KeyWord.Finalize_;

public class Case {
    public static void main(String[] args) {
        Car car = new Car("布加迪威龙");
        //此时对象没有被引用
        car = null;
        System.gc();
        //运气很不好？没有执行垃圾回收机制，可能是其他原因导致
        System.out.println("程序推出");
    }
}

class Car {
    private String name;

    public Car(String name) {
        this.name = name;
    }

    protected void finalize(String name) throws Throwable {

        System.out.println("销毁了 汽车" + name);
    }
}




